﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Xww.LCV {
    public struct MiningParam {
        public int MinInterval { get; set; }
        public int MaxInterval { get; set; }
        public int Threshold { get; set; }
        public char[] IgnoreList { get; set; }
        public MiningType MiningType { get; private set; }
        public bool IsDiscrete { get; private set; }
        public double ProbabilityDrop { get; private set; }
        public double Alpha { get; private set; }
        //internal LCSMiningParam() {
        //    MinInterval = 0;
        //    IgnoreList = IGNORE_LIST;
        //}
        public static MiningParam CreateAbsolute(int threshold) {
            MiningParam rst =  new MiningParam();
            rst.MiningType = MiningType.AbsolutePosition;
            rst.Threshold = threshold;
            return rst;
        }
        public static MiningParam CreateRelativeProbability() {
            return CreateRelativeProbability(0.9, 0.2, 4, int.MaxValue, false);
        }
        public static MiningParam CreateRelativeProbability(double probDrop, double alpha, int minSpan, int maxSpan, bool isDiscrete) {
            MiningParam rst = new MiningParam();
            rst.MiningType = MiningType.ConsecutiveSP;
            rst.ProbabilityDrop = probDrop;
            rst.Alpha = alpha;
            rst.MinInterval = minSpan;
            rst.MaxInterval = maxSpan;
            rst.IsDiscrete = isDiscrete;
            return rst;
        }
        public static MiningParam CreateConsecutiveSP(int threshold, int minSpan, int maxSpan) {
            MiningParam rst = new MiningParam();
            rst.MiningType = MiningType.ConsecutiveSP;
            rst.MinInterval = minSpan;
            rst.MaxInterval = maxSpan;
            rst.Threshold = threshold;
            return rst;
        }
        public static MiningParam CreateRelativeThreshold(int threshold) {
            MiningParam rst = new MiningParam();
            rst.MiningType = MiningType.RelativePositionThreshold;
            rst.Threshold = threshold;
            return rst;
        }
        public static MiningParam CreateRelativeThreshold(int threshold, int minSpan, int maxSpan) {
            MiningParam rst = new MiningParam();
            rst.MiningType = MiningType.RelativePositionThreshold;
            rst.Threshold = threshold;
            rst.MinInterval = minSpan;
            rst.MaxInterval = maxSpan;
            return rst;
        }
        

        public static char[] IGNORE_LIST = "\"· ，。、＝　…\t<>:.[]：||{}/\\+-*!@#$%^&()0123456789".ToCharArray();
    }
    public enum MiningType {
    ///<summary>Absolute position in equal length sequences</summary>
        AbsolutePosition,
    ///<summary>Find long-consecutive peptides at low threshold (e.g. 5), like Specific Peptides</summary>
        ConsecutiveSP,
        ///<summary>Relative position in unequal length sequences using threshold as filters</summary>
        RelativePositionThreshold
    }
}
